import { Request } from './axios-config';
// import { SetStroageItem, GetStroageItem } from '@/utils/storage-utils';
import {
  ACE_AUTH,
  ACE_ADMIN,
  RUC_SERVICE,
  ACE_BPM,
  ACE_TOOL
} from './constant';

// 账号密码登录
export const Login = async (data) => {
  return await Request({
    method: 'POST',
    url: `${ACE_ADMIN}/login`,
    data
  }).then((res) => res);
};

// 获取图片验证码
export const GetValidCode = async (data = {}) => {
  const res = await Request.get({
    url: `${ACE_ADMIN}/code`,
    custom: true,
    data
  });
  return res;
};

// 获取用户菜单
export const GetUserMenu = async (data) => {
  return await Request({
    method: 'GET',
    url: `${ACE_ADMIN}/baseMenu/font/menu`,
    data
  }).then((res) => {
    return res.data;
  });
};

// 获取用户信息
export const GetUserInfo = async (data) => {
  return await Request({
    method: 'GET',
    url: `${ACE_ADMIN}/user/getUserInfo`,
    data
  }).then((res) => res.data);
};

// 获取组织
export const GetOrgTreeData = async (data) => {
  return await Request({
    method: 'GET',
    url: `${ACE_ADMIN}/org/treeData`,
    data
  }).then((res) => res.data);
};

// 根据附件id获取url
export const GetFileUrl = async (data) => {
  return await Request({
    method: 'GET',
    url: `${RUC_SERVICE}/attachment/geturl`,
    params: data
  }).then((res) => res);
};

// 根据附件id获取内容
export const GetFileContent = async (data) => {
  return await Request({
    method: 'GET',
    url: `${ACE_TOOL}/oss/download`,
    params: data
  }).then((res) => res);
};

// 上传文件
export const UploadFile = async (data) => {
  return await Request({
    method: 'POST',
    url: `${ACE_TOOL}/oss/upload`,
    data
  }).then((res) => res);
};

//首页获取我的待办
export const GetMyTaskList = async (data) => {
  const res = await Request.post({
    url: `${ACE_BPM}/apiTaskRecord/my/need/dealt/list`,
    data
  });
  return res;
};
//首页获取我发起的
export const GetMyProcessList = async (data) => {
  const res = await Request.post({
    url: `${ACE_BPM}/apiTaskRecord/my/apply/list`,
    data
  });
  return res;
};
//首页我的待办操作请求
export const OperationMyTask = async (data) => {
  const res = await Request.post({
    url: `${ACE_BPM}/taskRecord/fastTaskAction`,
    data
  });
  return res;
};
